package at.jku.se.fastsell.data;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

public class SampleDataProvider {

	private static List<User> users = new LinkedList<User>();
	private static List<Auction> auctions = new LinkedList<Auction>();

	// ----------------------------------------------------------------------------------

	static {
		User u1 = new User("user1", "pwd");
		User u2 = new User("user2", "pwd");
		User u3 = new User("user3", "pwd");

		users.add(u1);
		users.add(u2);
		users.add(u3);

		SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy hh:mm");
		try {
			Date startDate = sdf.parse("04.06.2014 08:30");
			Date endDate = sdf.parse("05.06.2014 11:30");
			Date in5min = new Date(System.currentTimeMillis() + (1000 * 60 / 2));

			Auction a1 = new Auction(12345, "iPhone 4s",
					"Auction 1 description", u1, 10.5, startDate, endDate);
			Auction a2 = new Auction(23456, "Product 2",
					"Auction 2 description", u1, 15.5, startDate, in5min);
			Auction a3 = new Auction(34567, "Product 3",
					"Auction 3 description", u1, 15.5, startDate, endDate);
			Auction a4 = new Auction(45678, "Product 4",
					"Auction 4 description", u2, 15.5, startDate, endDate);
			Auction a5 = new Auction(1, "Notebook", "Notebook descriptions",
					u3, 450.5, 3);

			auctions.add(a1);
			auctions.add(a2);
			auctions.add(a3);
			auctions.add(a4);
			auctions.add(a5);

			a1.addBid(u3, 12);
			a1.addBid(u2, 13);
			a2.addBid(u3, 20);
			a4.addBid(u1, 20);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	// ----------------------------------------------------------------------------------

	public static List<Auction> getAuctions() {
		return auctions;
	}

	public static List<User> getUsers() {
		return users;
	}

	// ----------------------------------------------------------------------------------

	public static void addAuction(Auction a) {
		auctions.add(a);
	}

	public static void addUser(User u) {
		users.add(u);
	}

}
